using System;
using System.Collections.Generic;
using System.Text;
using TelnetExpect;
using System.IO;
using NUnit.Framework;

namespace TelnetTests
{
    public class TelnetBaseStreamTests_NegotiationNegative : TelnetStream_NegotiationNegative
    {
        protected override void DoTest(byte[] data, byte[] expectedInput, byte[] expectedResponses,
            Action<TelnetStream> modifyStreamBefore,
            TelnetOption[] expectedLocalOptions, TelnetOption[] expectedRemoteOptions,
            byte[] expectedSubNeg)
        {
            //const bool DoOnlyOneReadOperation = false;
            MemoryStream src0 = new MemoryStream(data);
            Stream src = Modifier_CreateStream(src0);
            MemoryStream dst = new MemoryStream();
            Stream conn = new PairStream(src, dst);
            TelnetBaseStream strm = new TelnetBaseStream(conn);
            byte[] result;
            int offset;
            Create_ResultBuffer(data.Length, out result, out offset);
            int totalLen = 0;
            while (true) {
                int readLen = strm.Read(result, offset + totalLen, result.Length - offset - totalLen);
                if (readLen == 0) {
                    break;
                }
                totalLen += readLen;
                //if (DoOnlyOneReadOperation) {
                //    break;
                //}
            }
            // Assert
            Assert.IsTrue(strm.IsAtNormalState, "IsAtNormalState");
            Assert_Buffers_AreEqual(expectedInput, result, offset, totalLen, "Input");
            if (expectedResponses != null) {
                //byte[] output = dst.ToArray();
                //Assert_Buffers_AreEqual(expectedResponses, output, 0, output.Length, "Responses");
                Assert_Buffers_AreEqual(expectedResponses, dst, "Responses");
            }
        }

    }
}
